package com.certapp.dao.mapper;

import com.certapp.dao.entity.TbToken;
import com.certapp.dao.entity.TbTokenExample;
import java.util.List;
import java.util.Optional;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface TbTokenMapper {

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_token
     *
     * @mbg.generated
     */
    @SelectProvider(type = TbTokenSqlProvider.class, method = "countByExample")
    long countByExample(TbTokenExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_token
     *
     * @mbg.generated
     */
    @DeleteProvider(type = TbTokenSqlProvider.class, method = "deleteByExample")
    int deleteByExample(TbTokenExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_token
     *
     * @mbg.generated
     */
    @Delete({ "delete from tb_token", "where token = #{token,jdbcType=VARCHAR}" })
    int deleteByPrimaryKey(String token);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_token
     *
     * @mbg.generated
     */
    @Insert({ "insert into tb_token (token, value, ", "expire_time, create_time)", "values (#{token,jdbcType=VARCHAR}, #{value,jdbcType=VARCHAR}, ", "#{expireTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP})" })
    int insert(TbToken record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_token
     *
     * @mbg.generated
     */
    @InsertProvider(type = TbTokenSqlProvider.class, method = "insertSelective")
    int insertSelective(TbToken record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_token
     *
     * @mbg.generated
     */
    @SelectProvider(type = TbTokenSqlProvider.class, method = "selectByExample")
    @Results({ @Result(column = "token", property = "token", jdbcType = JdbcType.VARCHAR, id = true), @Result(column = "value", property = "value", jdbcType = JdbcType.VARCHAR), @Result(column = "expire_time", property = "expireTime", jdbcType = JdbcType.TIMESTAMP), @Result(column = "create_time", property = "createTime", jdbcType = JdbcType.TIMESTAMP) })
    List<TbToken> selectByExample(TbTokenExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_token
     *
     * @mbg.generated
     */
    @Select({ "select", "token, value, expire_time, create_time", "from tb_token", "where token = #{token,jdbcType=VARCHAR}" })
    @Results({ @Result(column = "token", property = "token", jdbcType = JdbcType.VARCHAR, id = true), @Result(column = "value", property = "value", jdbcType = JdbcType.VARCHAR), @Result(column = "expire_time", property = "expireTime", jdbcType = JdbcType.TIMESTAMP), @Result(column = "create_time", property = "createTime", jdbcType = JdbcType.TIMESTAMP) })
    TbToken selectByPrimaryKey(String token);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_token
     *
     * @mbg.generated
     */
    @UpdateProvider(type = TbTokenSqlProvider.class, method = "updateByExampleSelective")
    int updateByExampleSelective(@Param("record") TbToken record, @Param("example") TbTokenExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_token
     *
     * @mbg.generated
     */
    @UpdateProvider(type = TbTokenSqlProvider.class, method = "updateByExample")
    int updateByExample(@Param("record") TbToken record, @Param("example") TbTokenExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_token
     *
     * @mbg.generated
     */
    @UpdateProvider(type = TbTokenSqlProvider.class, method = "updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(TbToken record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_token
     *
     * @mbg.generated
     */
    @Update({ "update tb_token", "set value = #{value,jdbcType=VARCHAR},", "expire_time = #{expireTime,jdbcType=TIMESTAMP},", "create_time = #{createTime,jdbcType=TIMESTAMP}", "where token = #{token,jdbcType=VARCHAR}" })
    int updateByPrimaryKey(TbToken record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_token
     *
     * @mbg.generated
     */
    @Options(useGeneratedKeys = true, keyProperty = "token", keyColumn = "token")
    @Insert({ "<script>", "insert into tb_token (token, ", "value, expire_time, ", "create_time)", "values<foreach collection=\"list\" item=\"detail\" index=\"index\" separator=\",\">(#{detail.token,jdbcType=VARCHAR}, ", "#{detail.value,jdbcType=VARCHAR}, #{detail.expireTime,jdbcType=TIMESTAMP}, ", "#{detail.createTime,jdbcType=TIMESTAMP})</foreach></script>" })
    int batchInsert(List<TbToken> list);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_token
     *
     * @mbg.generated
     */
    @SelectProvider(type = TbTokenSqlProvider.class, method = "getOneByExample")
    @Results({ @Result(column = "token", property = "token", jdbcType = JdbcType.VARCHAR, id = true), @Result(column = "value", property = "value", jdbcType = JdbcType.VARCHAR), @Result(column = "expire_time", property = "expireTime", jdbcType = JdbcType.TIMESTAMP), @Result(column = "create_time", property = "createTime", jdbcType = JdbcType.TIMESTAMP) })
    Optional<TbToken> getOneByExample(TbTokenExample example);
}
